// Copyright 2019 The rhyme_lph Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// K [author] rhyme_lph
// S [email]  rhymelph@gmail.com
// t [github] https://github.com/rhymelph

import 'package:base_plugin/base_plugin.dart';
import 'package:dio/src/response.dart';
import 'package:finance_app/src/common/config.dart';
import 'package:finance_app/src/entities/chat_room_message_entity.dart';
import 'package:finance_app/src/http_service/http_assistant_service.dart';
import 'package:finance_app/src/mixin/chat_room_action_mixin.dart';
import 'package:finance_app/src/mixin/refresh_mixin.dart';
import 'package:flutter/material.dart';
import 'package:finance_app/src/page/ace_virtual_assistant/notification_page.dart';

class NotificationProvider extends BaseProvider<List<ChatRoomMessageEntity>>
    with RefreshMixin, ChatroomActionMixin {
  @override
  int get initPage => 0;

  @override
  Future get dataFuture =>
      HttpAssistantService.chatRoomNotification(page, rows);

  @override
  List<ChatRoomMessageEntity> get dataList => data;

  @override
  List<ChatRoomMessageEntity> getFromRequestResult(
      Response<dynamic> result, bool isRefresh) {
    return getEntityFromResult(result);
  }

  @override
  Future get refreshFuture => dataFuture;

  @override
  FutureOr<List<ChatRoomMessageEntity>> transformData(
      List<ChatRoomMessageEntity> d, bool isCache) async {
    await Config.refreshMessageCount();
    return super.transformData(d, isCache);
  }
}
